package com.cn.test.record;

/**
 * description: 链表节点
 *
 * @author twj
 * @date 2021/7/23 9:59 .
 */
public class ListNode {

    int val;
    ListNode next;

    ListNode() {
    }

    ListNode(int val) {
        this(val, null);
    }

    ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        ListNode cur = this;
        while (cur != null) {
            sb.append(cur.val +" --> ");
            cur = cur.next;
        }
        sb.append("NULL");
        return sb.toString();

    }
}
